import request from 'umi-request';

export async function employeesList(params,value = {}) {
  return request('/hr-ssc/api/api-admin/hrEvent/list', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      employeeOid:params.employeeOid,
      isEntryStatus:parseInt(value),
      name:params.name,
      orgname:params.orgname,
      unitname:params.unitname,
      jobname:params.jobname,
      isShowAuthorityLog:true,
      status:[3]
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function updateEmployeesInfo(params) {
  return request('/hr-ssc/api/api-admin/newEmployees/updateLast', {
    method: 'POST',
    data: {
      ...params
    },
  }).then((res) => {
    return res;
  });
}

export async function getSysAuthorityLogByOidPage(oid) {
  return request('/hr-ssc/api/api-admin/userUpdateInfo/getSysAuthorityLogByOidPage', {
    method: 'post',
    data: {
      oid:oid,
      pageNum: 1,
      pageSize: 20,
    },
    requestType:'form'
  }).then((res) => {
    return res;
  });
}

export async function getEmployeeById(id) {
  return request(`/hr-ssc/api/api-admin/hrEvent/getEmployeeById/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function updateInfo(params) {
  return request('/hr-ssc/api/api-admin/hrEvent/updateMainInfo', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then((res) => {
    return res.flag;
  });
}

export async function getJobByOrgId(id) {
  return request(`/hr-ssc/api/api-admin/job/findJobByOrgId/${id}`, {
    method: 'get'
  }).then((res) => {
    return res.data;
  });
}
